package ar.com.sudoku.model;

import java.util.Collection;

public abstract class Grid {

	public abstract SudokuNumber get(SudokuNumber x, SudokuNumber y);
	public abstract void set(SudokuNumber x, SudokuNumber y, SudokuNumber number);
	public abstract Collection<SudokuNumber> getValues();
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Grid grid = (Grid) obj;
		for (SudokuNumber x : SudokuNumber.values()) {
			for (SudokuNumber y : SudokuNumber.values()) {
				if (this.get(x, y) == null) {
					if (grid.get(x, y) == null) {
						return true;
					}
					return false;
				}
				if (!this.get(x,y).equals(grid.get(x, y))) {
					return false;
				}
			}
		}
		return true;
	}
	
	@Override
	public String toString() {
		String grid = "";
        for (SudokuNumber x : SudokuNumber.values()) {
        	for (SudokuNumber y : SudokuNumber.values()) {
                grid += this.get(x,y) + " ";
        	}
        	grid += '\n';
        }
        return grid;
	}
	
	@Override
	public abstract Object clone();

}
